<?php
//use Phalcon\Session\Adapter\Files as Session;
class IndexController extends BaseController
{
	public function indexAction()
	{
		//$this->load();
		parent::load([
			'title'=>'首页',
			'css'=>'index',
			'js'=>'index'
		]);
		
		//为模板赋值
		$uInfo = $this->infoUser();
		$user = isset($uInfo['user_name'])? $uInfo['user_name']:null;
		//$orilUri = str_replace('http://','',url('G'));
		$orilUri = url('G');
		$data2draw = array();
		if($user){
			$userState = '<span>欢饮您,<a href="/TeClan/Clan/Index">'.$user.'</a></span><a href="http://'.getIp().'/Doeeking/index.php/Home/Index/quit?src='.$orilUri.'">注销</a>';
			$center = new Center();
			$data = Center::find('user_code="'.$uInfo['user_code'].'"');
			$genList = '';
			foreach($data as $v){
				$genList .= '<li>
					<a href="/TeClan/Clan/Index?no='.$v->gen_no.'" title="'.$v->gen_desc.'">'.$v->gen_title.'</a>
					<span class="auther"><a href="javascript:void(0);">'.$v->user_name.'</a></span>
					<span class="date"><a href="javascript:void(0);">'.$v->mtime.'</a></span>
				</li>';
			}
			if($genList) $genList = '<ul>'.$genList.'</ul>';
			$data2draw['genList'] = $genList;
		} 
		else $userState = '<a href="http://'.getIp().'/Doeeking/index.php/Home/Index/enter?src='.$orilUri.'" target="_blank">登入</a>';
		$data2draw['userstate'] = $userState;

		$this->view->setVars($data2draw);
	}
	public function testAction()
	{
		echo phpinfo();
		//echo'<pre>';print_r($this);
	}
}
